//tslint:disable
import { Component, OnInit, Input } from '@angular/core';
import { ModalController, AlertController, LoadingController } from "@ionic/angular";

@Component({
  selector: 'app-myreal-estate',
  templateUrl: './myreal-estate.component.html',
  styleUrls: ['./myreal-estate.component.scss'],
})
export class MyrealEstateComponent implements OnInit {
  @Input() tagData: any;
  listData: any;
  selectId = 0;
  constructor(public modalController: ModalController) { }

  ngOnInit() {
    this.listData = this.tagData;
    this.listData.forEach(element => {
      if (element.data.headDiv.type === 'quickWay') {
        if (localStorage.getItem('myrealEstatequickWay')) {
          this.selectId = parseInt(localStorage.getItem('myrealEstatequickWay'));
        } else {
          this.selectId = 0;
        }
      } else if (element.data.headDiv.type === 'resetAssured') {
        if (localStorage.getItem('myrealEstateresetAssured')) {
          this.selectId = parseInt(localStorage.getItem('myrealEstateresetAssured'));
        } else {
          this.selectId = 0;
        }
      }
    });
  }
  // 传值
  go(e, data, type?, selId?) {
    e.stopPropagation();
    if (type !== undefined) {
      this.selectId = selId;
      const storeId = 'myrealEstate' + type;
      localStorage.setItem(storeId, this.selectId + '');
      const storeOppId = 'myrealEstateOppId';
      if (data.link.params.opp_id2) {
        localStorage.setItem(storeOppId, data.link.params.opp_id2);
      }

    }

    let tmpType;
    if (type) {
      tmpType = type;
    } else if (data.link.params.tmpType !== undefined) {
      tmpType = data.link.params.tmpType;
    }
    this.modalController.dismiss({ dismissed: true, itemdata: data, type: tmpType });


  }
  close(e) {
    this.modalController.dismiss({ dismissed: true });
  }
}
